package com.qiyu.tech.pay.queue;

import com.alibaba.fastjson.JSON;
import com.qiyu.core.cache.redis.client.RedisService;
import com.qiyu.tech.pay.queue.model.DelayTaskInfo;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author linhao
 * @Date created in 3:11 下午 2021/4/4
 */
@Component
public class NotifyRetryTaskInfoManager {

    @Resource
    private RedisService redisService;

    private static final String NOTIFY_RETRY_TASK_INFO_MAP = "notify:retry:task:info:map";


    public boolean put(long taskId, DelayTaskInfo delayTaskInfo) {
        return redisService.setMapItem(NOTIFY_RETRY_TASK_INFO_MAP, String.valueOf(taskId), JSON.toJSONString(delayTaskInfo));
    }

    public boolean delete(long taskId) {
        return redisService.deleteMapItem(NOTIFY_RETRY_TASK_INFO_MAP, String.valueOf(taskId));
    }
}
